<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录页-一个短网址（A Short Url）</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
    <link rel="icon" href="/favicon.ico" type="image/ico">
    <meta name="keywords" content="">
    <meta name="description" content="">
    <meta name="author" content="CongRui.Zheng YanBin.Qi">
    <link href="/static/css/bootstrap.min.css" rel="stylesheet">
    <link href="/static/css/materialdesignicons.min.css" rel="stylesheet">
    <link href="/static/css/style.min.css" rel="stylesheet">
    <style>
        .container {
            width: 100vw;
            height: 100vh;
            display: flex;
            background: url("/static/images/login-bg.jpg");
            background-size: 100%;
            justify-content: center;
            align-items: center;
        }

        .login-container {
            width: 30%;
            height: 100%;
            background: #ffffff;
            display: flex;
            align-items: center;
        }

        .login-box {
            width: 100%;

        }

        .text-center {
            text-align: center;
        }

        .ui-slider-wrap {
            background: #ececec;
            position: relative;
            -webkit-border-radius: 2px;
            border-radius: 2px;
        }

        .ui-slider-wrap .ui-slider-bg {
            width: 0;
            -webkit-border-radius: 2px;
            border-radius: 2px;
        }

        .ui-slider-wrap .ui-slider-btn {
            position: absolute;
            top: 0;
            left: 0;
            cursor: move;
            text-align: center;
            box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.125);
            background: #fff;
            -webkit-border-radius: 2px;
            border-radius: 2px;
        }

        .ui-slider-wrap .ui-slider-btn {
            background: #fff;
        }

        .ui-slider-wrap .ui-slider-btn:before {
            display: inline-block;
            font: normal normal normal 24px/1 "Material Design Icons";
            font-size: inherit;
            text-rendering: auto;
            line-height: inherit;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
            content: "\f13e";
        }

        .ui-slider-wrap .ui-slider-btn.success:before {
            content: "\f12c";
        }

        .ui-slider-wrap .ui-slider-text {
            width: 100%;
            height: 100%;
            text-align: center;
            position: absolute;
            top: 0;
            left: 0;
            color: #4d5259;
        }

        .ui-slider-wrap .ui-slider-no-select {
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            -o-user-select: none;
            user-select: none
        }
    </style>
</head>

<body>
<div class="container">
    <div class="login-container">
        <div class="login-box">
            <div class="text-center">
                <a href="/"> <img alt="light year admin" src="/static/images/logo.png"> </a>
            </div>
            <div class="text-center text-muted">
                请使用账号密码登录
            </div>

            <form action="#!" method="post" style="padding: 0px 40px;margin-top:25px;">
                <div class="form-group">
                    <label for="username">用户名</label>
                    <input type="text" class="form-control" id="username" placeholder="请输入您的用户名、手机号码、邮箱">
                </div>

                <div class="form-group">
                    <label for="password">密码</label>
                    <input type="password" class="form-control" id="password" placeholder="请输入您的密码">
                </div>
                <div class="form-group">
                    <div id="slider-verification" class="slider"></div>
                </div>
                <div class="form-group">
                    <div class="custom-control custom-checkbox">
                        <input type="checkbox" class="custom-control-input" id="rememberme" name="rememberme">
                        <label class="custom-control-label not-user-select" for="rememberme">5天内自动登录</label>
                    </div>
                </div>

                <div class="form-group">
                    <a class="btn btn-block btn-primary" href="javascript:void(0);" onclick="submit()">立即登录</a>
                </div>
                <div class="form-group">
                    <div style="text-align: left;display: inline-block;width: 50%">
                        <a href="mobile"><i class="mdi mdi-cellphone"></i>手机号码登录</a>
                    </div>
                    <div style="text-align: right;display: inline-block;width: 49%">
                        <a href="email"><i class="mdi mdi-email"></i>邮箱验证码登录</a>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
<script type="text/javascript" src="/static/js/jquery.min.js"></script>
<script type="text/javascript" src="http://libs.itshubao.com/jquery.sliderVerification.min.js"></script>
<script src="/static/js/bootstrap-notify.min.js"></script>
<script type="text/javascript" src="/static/js/lightyear.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        var width = $('.form-group').css('width');
        width.replace('px', '');
        $("#slider-verification").slider({
            width: parseInt(width),                     // width
            height: 38,                     // height
            sliderBg: "#f9fafb",            // 滑块背景颜色
            color: "#8b95a5",               // 文字颜色
            fontSize: 14,                   // 文字大小
            bgColor: "#15c377",             // 背景颜色
            textMsg: "按住滑块，拖拽验证",     // 提示文字
            successMsg: "验证通过",       // 验证成功提示文字
            successColor: "#fff",           // 滑块验证成功提示文字颜色
            time: 400,                      // 返回时间
            callback: function (result) {    // 回调函数，true(成功),false(失败)
                $(".resultSpan").text(result);
            }
        });
    });

    function submit() {
        let username = $('#username').val(),
            password = $('#password').val(),
            rememberme = $('#rememberme').val();

        if (username == '' || password == '') {
            lightyear.notify('请先通过滑动验证', 'danger', 1000, '', 'top', 'center')
            return;
        }
        rememberme = rememberme == 'on' ? true : false;
        $.ajax({
            url: '',
            method: 'post',
            data: {
                username: username,
                password: password,
                rememberme: rememberme
            },
            success: function (res) {
                if (res.code !== 200) {
                    $("#slider-verification").slider("restore");
                    lightyear.notify(res.message, 'warning', 1000, '', 'top', 'center')

                } else {
                    setTimeout(function () {
                        location.href = res.data.url;
                    }, 1500);
                }
            }
        })
    }
</script>
</html>
